(function () {
  window.changePage = new Vue({
    el: '#changePage',
    data() {
      return {
        id: hlUrlUtil.GetQueryString('id'),//合同ID
        code: hlUrlUtil.GetQueryString('code'),//变更code
        condition: hlUrlUtil.GetQueryString('condition'),//变更内容
        steps: [],
        pageIndex: window.sessionStorage.getItem('pageIndex') || 0,
      }
    },
    watch: {
      pageIndex() {
        window.sessionStorage.setItem('pageIndex', this.pageIndex)
        if(this.pageIndex < 0){
          window.sessionStorage.setItem('pageIndex', 0)
          window.history.back()
        }
      }
    },
    computed: {
      _isDisabledList() {
        return this.steps.join('')
      },
      _titleText() {
        let num = this.steps[this.pageIndex]
        if (num == 0) {
          $('.content').load('modules/contratchange/page/basic_change.html')
          return '合同变更-基本信息变更'
        }
        if (num == 1) {
          $('.content').load('modules/contratchange/page/clause_change.html')
          return '合同变更-条款变更-房源信息'
        }
        if (num == 2) {
          $('.content').load('modules/contratchange/page/contract_change.html')
          return '合同变更-条款变更-租约费项'
        }
        if (num == 3) {
          $('.content').load('modules/contratchange/page/change_content.html')
          return '合同变更-变更内容确认'
        }
        if (num == 4) {
          $('.content').load('modules/contratchange/page/conflict.html')
          return '合同变更-冲突账单确认'
        }
      }
    },
    methods: {

    },
    mounted() {
      window.onpopstate = function () {
        if(window.location.href.indexOf('#/contractChangeIndex') == -1){
          window.onpopstate = null;
          sessionStorage.clear();
        }
      }
      if (this.condition.indexOf('YB') != -1 && this.condition.indexOf('CW') == -1) {
        this.steps = [0,3]
      }
      if (this.condition.indexOf('YB') == -1 && this.condition.indexOf('CW') != -1) {
        this.steps = [1, 2, 3, 4]
      }
      if (this.condition.indexOf('YB') != -1 && this.condition.indexOf('CW') != -1) {
        this.steps = [0, 1, 2, 3, 4]
      }
    },
  })
}())
